package com.itheima.TCPdemo;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

//TCP协议，接收数据，服务器
public class Server {
    public static void main(String[] args) throws IOException {
        //1.创建对象
        ServerSocket ss=new ServerSocket(10000);

        //2.监听客户端的连接,死等客户端来连接，不然卡死这一步
        Socket socket = ss.accept();
        InputStream is = socket.getInputStream();//通过通道对象得到输入流

        int b=0;
        while ((b=is.read())!=-1){
            System.out.println((char)b);
        }
        socket.close();//断开了和客户端的连接
        ss.close();//关闭了服务器
    }
}
